﻿@inject NavigationManager NavigationManager
@inject IDataCacheService _dataCacheService

<MDCard Class="pa-3 mb-3">
    <div style=" display: flex; justify-content: space-around; ">
        <div style=" display: flex; flex-direction: column; align-items: center; ">
            <div class="title-large">@Model.BasicInfor.EditCount</div>
            <div class="label-large">累计编辑</div>
        </div>
        <div style=" display: flex; flex-direction: column; align-items: center; ">
            <div class="title-large">@Model.BasicInfor.ArticleCount</div>
            <div class="label-large">发表文章</div>
        </div>

        <div style=" display: flex; flex-direction: column; align-items: center; ">
            <div class="title-large">@Model.BasicInfor.ArticleReadCount</div>
            <div class="label-large">阅读总数</div>
        </div>
    </div>
    <div class="mb-4 mt-3">
        <div style=" display: flex; justify-content: space-between;">
            @{ int level = ToolHelper.GetUserLevel(Model.BasicInfor.Integral);}
            <span>
                <i class="primary-textfa fa-magic fa-fw"></i>@("Lv："+level)
            </span>
            <span style=" color: gray;">
                @(level==10?Model.BasicInfor.Integral:(Model.BasicInfor.Integral+" / "+ToolHelper.GetLevelIntegral(level)))
            </span>
        </div>
        <MProgressLinear Value="@(level==10?100:(100.0*Model.BasicInfor.Integral/ToolHelper.GetLevelIntegral(level)))" ></MProgressLinear>
    </div>
    @if (Model.IsCurrentUser)
    {
        <div style="display: flex; justify-content: flex-end; margin-bottom: -40px;">
            <CnGalWebSite.Components.Buttons.MasaButton Fab Icon="mdi-pencil " Tooltip="编辑个人资料" OnClick="OnClickEdit" />
        </div>

    }
    <div class="row">
        <CnGalWebSite.Shared.MasaComponent.Shared.Components.IconText Icon="IconType.Count" Text="@("贡献值："+Model.ContributionValue)" Class="col-12" /> 

        @if (Model.Birthday != null)
        {
            <CnGalWebSite.Shared.MasaComponent.Shared.Components.IconText Icon="IconType.Birthday" Text="@("生日："+Model.Birthday.Value.ToString("M月d日") )" Class="col-12" /> 

        }
        <CnGalWebSite.Shared.MasaComponent.Shared.Components.IconText Icon="IconType.Duration" Text="@("在线时间："+ Model.OnlineTime.ToString("0.0")+"小时")" Class="col-12" />
        <CnGalWebSite.Shared.MasaComponent.Shared.Components.IconText Icon="IconType.DeterminedTime" Text="@("注册时间："+Model.RegisteTime.ToString("yyyy-MM-dd HH:mm"))" Class="col-12" />
        <CnGalWebSite.Shared.MasaComponent.Shared.Components.IconText Icon="IconType.IndeterminateTime" Text="@("最后访问："+Model.LastOnlineTime.ToString("yyyy-MM-dd HH:mm"))" Class="col-12" /> 
        @if (Model.LastEditTime != null)
        {
            <CnGalWebSite.Shared.MasaComponent.Shared.Components.IconText Icon="IconType.EditTime" Text="@("上次编辑时间："+Model.LastEditTime.Value.ToString("yyyy-MM-dd HH:mm"))" Class="col-12" />
        }
        <CnGalWebSite.Shared.MasaComponent.Shared.Components.IconText Icon="IconType.Identity" Text="@("UID："+Model.Id)" Class="col-12" />
    </div>

</MDCard>

@code {
    [Parameter]
    public PersonalSpaceViewModel Model { get; set; }


    public void OnClickEdit()
    {
        NavigationManager.NavigateTo("/space/editdata/" + Model.Id);
       
    }

}
